﻿using Pyramid.Hardware.Gates;

namespace Pyramid.Hardware
{
    public class MasterSlaveFlipFlop
        : FlipFlopBase
    {
        private DFlipFlop _master;
        private DFlipFlop _slave;
        private NotGate _clockInverter;

        public MasterSlaveFlipFlop(ILine data, ILine clock)
        {
            _master = new DFlipFlop(data, clock);

            _clockInverter = new NotGate(clock);

            _slave = new DFlipFlop(_master.Q, _clockInverter);
        }

#if DEBUG

        public ILine InternalQ
        {
            get
            {
                return _master.Q;
            }
        }

#endif

        public override ILine Q
        {
            get
            {
                return _slave.Q;
            }
        }
    }
}
